package com.example.tellwin.home.presenter;

import com.example.tellwin.api.TwjfApi;
import com.example.tellwin.base.RxPresenter;
import com.example.tellwin.base.SimpleCallback;
import com.example.tellwin.home.contract.TeacherDetailContract;
import com.example.tellwin.mine.bean.TeacherContentBean;
import com.example.tellwin.utils.HttpUtils;

import javax.inject.Inject;

import okhttp3.RequestBody;

/**
 * @author : LinZePeng
 * @date : 2020/11/26
 * @Describe ：
 **/
public class TeacherDetailPresenter extends RxPresenter<TeacherDetailContract.View> implements TeacherDetailContract.Presenter<TeacherDetailContract.View> {


    private TwjfApi mApi;

    @Inject
    public TeacherDetailPresenter(TwjfApi mApi) {
        this.mApi = mApi;
    }

    @Override
    public void getTeacherDetail(String teacherId) {
        mApi.getTeacherDetail(teacherId , new SimpleCallback<TeacherContentBean>(mView) {
            @Override
            public void onSuccess(TeacherContentBean contentBean) {
                mView.teacherDetailResult(contentBean);
            }

            @Override
            public void onFail(String msg) {

            }
        });
    }

    @Override
    public void attention(String teacherId) {
        RequestBody requestBody = HttpUtils.getRequestBody("followType", "1" + "", "relationId", teacherId, "relationType", "1");
        mApi.follow(requestBody, new SimpleCallback<Object>(mView) {
            @Override
            public void onSuccess(Object o) {
                mView.attention();
            }

            @Override
            public void onFail(String msg) {

            }
        });
    }
}
